<template>
  <div class="member-container">
    <!-- 头部 -->
    <div class="header"
         :class="[wxConfig.template_style == 1 ? 'style1-top' : 'style2-top header_bg_cure', memberInfo.show_privilege?'padding110':'padding16']"
         :style="{ backgroundImage: dggDz ? '' : 'url('+bgImg+')'}">
      <section class="infoPanel">
        <div class="avatar-box fl">
          <div class="avatar j-render"
               @click="renderAvatar"
               :style="{ backgroundImage:'url('+memberInfo.avatar+')'}"></div>
        </div>
        <ul class="userinfo fl" :style="{ color: fontColor }">
          <!-- 昵称 -->
          <li class="nickname">
            <span class="nickname-title"
                  v-if="memberInfo.nickname">{{memberInfo.nickname}}</span>
            <span class="nickname-title"
                  v-else>{{memberInfo.mobile}}</span>
            <span class="lit-spn bor"
                  v-if="memberInfo.show_level && memberInfo.rank_name">{{memberInfo.rank_name}}</span>
            <!-- 切换user-id -->
            <span class="edit-userid-btn" @click="editUserId" v-if="userStatus === 2">
              <!-- TODO 暂时隐藏svg -->
              <!-- <svg-icon icon-class="icon-edituserid" class="icon-edituserid"></svg-icon> -->
            </span>
          </li>

          <li>
            <!-- 注册时间 -->
            <span class="mgr15" v-if="memberInfo.show_id">用户ID：{{memberInfo.user_id}}</span>
            <!-- 消费金额 -->
            <span v-if="memberInfo.show_sum">消费金额：{{memberInfo.total_price}}</span>
          </li>
          <li class="">注册：{{memberInfo.create_time}}</li>
          <li class="" v-if="memberInfo.cjh_dz">优惠总金额：{{memberInfo.total_discount}}</li>
          <!--    梅之音 定制 上级代理微信  start      -->
          <li class="" v-if="weixin_account">上级服务商微信：{{weixin_account}}</li>
          <!--    梅之音 定制 上级代理微信  end      -->
          <!-- 冻结积分 -->
          <!-- <li class="point-info"
              v-if="memberInfo.show_top_point">
            <span class="lit-spn">{{memberInfo.point_name}}：{{memberInfo.points}}</span>
            <span class="lit-spn"
                  v-if="memberInfo.forzen_point>0">冻结{{memberInfo.point_name}}：{{memberInfo.forzen_point}}</span>
          </li> -->
          <!-- 粉红到期 -->
          <li v-if="memberInfo.hls_dz && memberInfo.bonus_end_time">
            分红到期：{{memberInfo.bonus_end_time}}
          </li>
        </ul>
        <div class="gotoMail"
            @click="Jump('letter')">
          <span class="num fontAliBaba">{{ getLetterCount(letterCount) }}</span>
        </div>
        <!--定制 我的导师 start-->
        <div class="my_teacher"
             v-if="memberInfo.is_my_mentor==1"
             @click="showMyTeacherPop"></div>
        <!-- 老师二维码 -->
        <van-popup v-model="showMyTeacher"
                   class="detail_qrcode_box"
                   v-if="memberInfo.is_my_mentor==1">
          <!-- <section class="qrcode_overlay" id="qrcode_overlay"></section> -->
          <div class="content">
            <div class="h">
              <div class="detail_qrcode_content">
                <h3 class="title">Hi，你好：</h3>
                <p class="text">我是您的服务老师，将为您提供一对一辅导，让您福利早知道，快来加我吧！</p>
                <div class="qrcode_box">
                  <img :src="memberInfo.my_mentor_qrcode_id"
                       alt />
                </div>
              </div>
            </div>
          </div>
          <div class="btn">
            <input type="hidden"
                   name="wxID"
                   v-model="memberInfo.my_mentor_wx_id" />
            <button class="copy j-copy"
                    @click="copyMentorWx(memberInfo.my_mentor_wx_id,$event)">复制微信号，去添加</button>
            <button class="noWarn"
                    @click="hideMyTeacherPop">我已添加，不再提醒</button>
          </div>
          <i class="J_closed_box closed_box"
             @click="hideMyTeacherPop"></i>
        </van-popup>
        <!--定制 我的导师 end-->

        <!-- <span class="j-toggle"
              v-if="memberInfo.is_checkin && memberInfo.show_level && (memberInfo.is_hide_qiandao!=1)"
              @click="toggleLevelQd">
          <img :src="memberInfo.icon_toggle" />
        </span> -->

        <div class="hd-input">
          <!--查看会员等级-->
          <!-- <div v-if="memberInfo.show_level && memberInfo.show_privilege">
            <a href="javascript:;"
               class="change_level"
               v-show="memberInfo.is_checkin && !memberInfo.showToggle"
               @click="Jump('memberBenefits')">
              v-show="is_checkin && (is_hide_qiandao==1)
              <div class="read_level">
                <span class="nk title"
                      v-if="memberInfo.rank_name">
                  <i class="user"></i>
                  {{memberInfo.rank_name}}
                </span>
                <span class="nk title"
                      v-else>
                  <i class="user"></i>会员等级
                </span>
                <div class="rd btn">
                  <span>查看</span>
                  <svg-icon icon-class="icon_linkto"
                            class="icon_linkto"></svg-icon>
                </div>
              </div>
            </a>
          </div> -->
          <!--签到-->
          <div v-if="memberInfo.is_checkin==1 && ( memberInfo.is_hide_qiandao!=1)">
            <a href="javascript:;"
               class="change_qiandao"
               v-show="memberInfo.is_checkin==1 "
               @click="Jump('/checkin')">
              <div class="qiandao">
                <div class="qd-btn btn">
                  <i></i>
                  <span>签到</span>
                  <!-- TODO svg换成img -->
                  <img class="icon_linkto" src="https://img.wifenxiao.com/h5-wfx/images/common/link-icon.png"/>
                </div>
              </div>
            </a>
          </div>
        </div>
      </section>
      <!-- 头部导航 -->
      <div class="head-nav" :style="{ color: fontColor }">
        <div class="link"
             @click="Jump('mycoupon')" v-if="memberInfo.show_my_coupon == 1">
          <span class="title_num">{{memberInfo.coupon_num}}</span>
          <span class="title">{{memberInfo.ftitle_coupon}}</span>
        </div>
        <div class="link"
             v-if="memberInfo.show_top_point"
             @click="Jump('point')">
          <span class="title_num">{{memberInfo.points}}</span>
          <span class="title">{{memberInfo.point_name}}</span>
        </div>
        <div class="link"
             @click="Jump('collectionGoods')" v-if="memberInfo.show_my_fav_goods == 1">
          <span class="title_num">{{memberInfo.collection_num}}</span>
          <span class="title">{{memberInfo.ftitle_collection}}</span>
        </div>
        <div class="link"
             @click="Jump('balanceTx')" v-if="memberInfo.show_my_balance == 1">
          <span class="title_num">{{memberInfo.balance}}</span>
          <span class="title">{{memberInfo.account_balance}}</span>
        </div>
        <div class="link"
             @click="Jump('bjhBalance')" v-if="memberInfo.bjh_balance_dz == 1">
          <span class="title_num">{{memberInfo.bjh_balance}}</span>
          <span class="title">百佳华余额</span>
        </div>
        <div class="link" @click="Jump('balanceTx')" v-if="gxl_balance_withdrawal_limit_dz">
          <span class="title_num">{{memberInfo.balance_limit}}</span>
          <span class="title">可提现额度</span>
        </div>
      </div>
      <!-- 会员卡特权 -->
      <div class="membership-card" v-if="memberInfo.show_privilege" :style="{'background-image':'url('+memberInfo.membership_level_img+')'}">
        <div class="card-text" :style="{'color':memberInfo.membership_level_color}">{{memberInfo.rank_name ? '会员等级：'+memberInfo.rank_name:'开通会员立享特权'}}</div>
        <div class="card-btn" @click="Jump('memberBenefits')">{{memberInfo.rank_name ? '查看权益':'立即开通'}}</div>
      </div>
      <div class="cover"></div>
    </div>
    <!-- 导航 -->
    <user-nav :memberData="memberData" :current="0"></user-nav>
    <!-- TODO 暂时只显示member-index2 -->
      <member-index :modifyUserPop="modifyUserPop" v-if="template_style == 1" :isAgreement="isAgreement" :memberInfo="memberInfo" @loginOut="loginOut" @selectMemberType="selectMemberType"></member-index>
      <member-index2 :modifyUserPop="modifyUserPop" v-else-if="template_style == 2" :isAgreement="isAgreement" :memberInfo="memberInfo" @loginOut="loginOut" @selectMemberType="selectMemberType"></member-index2>
    <!-- 修改userid遮罩层 -->
    <edit-user @RefreshPage="RefreshPage" :editInfo="editInfo"></edit-user>

    <!-- 修改授权手机号遮罩层 -->
    <get-mobile :memberInfo="memberInfo"></get-mobile>

    <!-- 定制   职乐（税筹）或通联（分账），用户二选一 -->
    <ChooseBill
      v-if="show_member_select"
      :checkValue="memberInfo.dz_fz_member_type"
      @select="menmberTypeSelected"
      @close="show_member_select = false"
    ></ChooseBill>

    <!-- 授权弹出框 -->
    <small-login ref="smalllogin"></small-login>
    <!-- 修改头像、昵称 -->
    <van-popup v-model="modifyUserPop" :close-on-click-overlay="false" position="bottom" :style="{ height: '55%' }" @close="closeClick">
      <div class="avatarInfo_wraps">
        <div class="shop-name">
          <div>
            <img :src="accountInfo.icon">
          </div>
          <div>
            {{accountInfo.nickname}}<span>申请</span>
          </div>
        </div>
        <div class="text">获取你的昵称、头像</div>
        <div>
          <div class="nickname">
            <div class="view-title">头像</div>
            <wx-button class="avatar" :class="avatarImg? 'backWhite':''" open-type="chooseAvatar" @chooseavatar="onChooseAvatar">
              <img v-if="avatarImg" class="avatar" :src="avatarImg" mode="aspectFill" />
              <img v-else class="avatar" src="https://img.wifenxiao.com/h5-wfx/images/default_avatar.jpg" mode="aspectFill" />
            </wx-button>
          </div>
          <div class="nickname">
            <div class="view-title">昵称</div>
              <input type="nickname" v-model="nicknameVal" :focus="focus" ref="nicknameVal" @focus="focusSubmit()" @blur="blurSubmit()" @input="inputChange" :maxlength="16" placeholder="请输入昵称" />
          </div>
        </div>
        <div class="submit-btn" @click="submitClick" v-if="submitShow">允许</div>
        <div class="cancel-btn" @click="closeCancel" v-if="submitShow">拒绝</div>
      </div>
    </van-popup>
  </div>
</template>

<script>
import Vue from 'vue'
import { mapGetters } from 'vuex'
import { getMemberInfo, sync, syncSaveInfo, quit, uptMsgInfo, getUsers, saveInformation } from '@/api/user/member/memberApi'
import userNav from '@/views/user/components/nav/index'
// import avatar from 'https://img.wifenxiao.com/h5-wfx/images/default_avatar.jpg'
// import icon_toggle from 'https://img.wifenxiao.com/h5-wfx/images/user/member/icon_toggle.png'
import memberIndex from './components/memberIndex/index'
import memberIndex2 from './components/memberIndex2/index'
import editUser from './components/edituser/index'
import getMobile from './components/getMobile/index'
// import handleClipboard from '@/utils/clipboard'
import SmallLogin from '@/components/SmallLogin/smallLogin'
import small from '@/smallapp/small.js'
import { openPage } from '@/utils/utils'
import StoreSave from '@/utils/store'
import { ChooseBill } from '@/views/layout/components'
export default Vue.extend({
  computed: {
    ...mapGetters(['wxConfig'])
  },
  components: {
    userNav,
    memberIndex,
    memberIndex2,
    editUser,
    getMobile,
    SmallLogin,
    ChooseBill
  },
  data() {
    return {
      showMyTeacher: false,
      letterCount: 0, // 站内信单独接口获取
      memberData: {},
      memberInfo: {},
      bgImg: 'https://img.wifenxiao.com/h5-wfx/images/user/member/user_style3_bg_black.png',
      fontColor: '#ffffff',
      editInfo: {
        show: false,
        radio: 1,
        editInfoData: []
      },
      // 是否显示切换按钮
      userStatus: 0,
      template_style: 1,
      weixin_account: '', // 梅之音生物 -- 上级代理商微信
      show_member_select: false, // 职乐-通联 分账二选一
      dggDz: false,
      modifyUserPop: false,
      nicknameVal: '',
      avatarUrl: '',
      avatarImg: '',
      accountInfo: {},
      submitShow: true,
      isSub: false,
      isAgreement: {
        register_agreement: 0,
        privacy_agreement: 0
      },
      needAuthorizationInput: false,
      focus: false,
      gxl_balance_withdrawal_limit_dz: 0 // 刚需连 可提现余额
    }
  },
  created() {
    // console.log(this.wxConfig)
    this.accountInfo = __wxConfig.accountInfo
    this.init()
    // 定制 东阿阿胶股 账号切换功能
    if (this.$route.query.sid === '4032023') {
      this.getUserData()
    }
    this.dggDz = this.$_shop('$_dgg_dz', small.globalData.shopId)
    if (this.$_shop('$_tdbl_dz', small.globalData.shopId)) {
      this.bgImg = 'https://img.wifenxiao.com//h5-wfx/images/user/member/dz_user_bg_orange.png'
    }

  },
  mounted() {
      if (!small.checkLogin()) {
        this.$refs.smalllogin.openSmallLoginPop()
      }
      window.$$subscribe('loginReload', reload => {
        if (reload) {
          this.init()
        }
      })
      // TODO 接收广播更新优惠券数量
      window.$$subscribe('refreshCoupon', data => {
        this.init()
      })
  },
  beforeDestroy() {
    window.$$unsubscribe('loginReload')
    window.$$unsubscribe('refreshCoupon')
  },
  methods: {
    focusSubmit() {
      this.submitShow = false
    },
    blurSubmit() {
      this.focus = false
      this.submitShow = true
    },
    inputChange(e) {
      this.nicknameVal = ''
        // console.log('inputChange', e.detail.value)
        this.nicknameVal = e.detail.value
      },
    Jump(url, data) {
      this.$JumpPath(this, url, data)
    },
    getLetterCount(num) {
      const mailNum = parseInt(num)
      return mailNum > 99 ? '99+' : num <= 0 ? '' : num
    },
    init() {
      this.$loadingWrap.show()
      this.uptMsgInfoFn()
      getMemberInfo().then(res => {
        this.$loadingWrap.close()
        if (res.status == 1) {
          const data = res.data
          // TODO 小程序处理 wxConfig.template_style
            data.template_style ? this.template_style = data.template_style : ''
            wx.setNavigationBarTitle({
              title: res.data.common_center_parameter.ftitle_user
            })
          // 导航数据
          this.memberData = Object.assign(data.common_center_parameter, data.common_center_renovation_parameter)
          // console.log(this.memberData)
          this.memberData.user_type = data.user_identity.user_type
          this.memberData.is_agent = data.user_identity.is_agent
          this.memberData.is_show_distributor = data.is_show_distributor
          this.memberData.system_function_model = data.system_function_model
          this.memberData.is_check_dhs = data.is_check_dhs
          this.memberData.is_show_dhs = data.is_show_dhs
          this.memberData.is_wx = data.is_wx
          this.memberData.is_app = data.is_app
          this.memberData.is_show_agent = data.is_show_agent
          this.memberData.is_show_gys = data.is_show_gys
          this.memberData.supplier_flag = data.supplier_flag
          this.memberData.is_tgy = data.is_tgy
          this.memberData.is_dls = data.is_dls
          this.memberData.ftitle_gys_center = data.ftitle_gys_center
          //  头部数据
          this.memberInfo = Object.assign(data.user_nicknames, data.user_info)
          // TODO 头像处理
          this.memberInfo.avatar = data.avatar.indexOf('http') > -1 ? data.avatar : 'https://img.wifenxiao.com/h5-wfx/images/default_avatar.jpg'
          this.avatarUrl = this.memberInfo.avatar
          this.nicknameVal = data.user_info.nickname
          this.avatarImg = this.memberInfo.avatar
          // console.log('nickname', this.memberInfo.nickname)

          if ((this.memberInfo.avatar == 'https://img.wifenxiao.com/h5-wfx/images/default_avatar.jpg' || this.memberInfo.nickname == '微信用户') && !this.isSub) {
            this.modifyUserPop = true
          }
          if (data.common_center_renovation_parameter.top_bg != '') {
            this.bgImg = data.common_center_renovation_parameter.top_bg
          }
          this.gxl_balance_withdrawal_limit_dz = data.gxl_balance_withdrawal_limit_dz || 0
          this.memberInfo.balance_limit = data.user_info.balance_limit || '¥ 0.00'
          // 字体的颜色
          if (data.template_style == 1) {
            this.fontColor = data.common_center_renovation_parameter.font_color1
          } else if (data.template_style == 2) {
            this.fontColor = data.common_center_renovation_parameter.font_color2
          }
          this.memberInfo.showShareLink = data.common_center_renovation_parameter.showShareLink
          // 订单转换
          this.memberInfo.is_order_convert = data.common_center_renovation_parameter.is_order_convert || 0
          this.memberInfo.order_convert_name = data.common_center_renovation_parameter.order_convert_name

          // 其他打包
          this.memberInfo.is_wx = data.is_wx
          this.memberInfo.isAfb = data.isAfb
          this.memberInfo.isAppIos = data.isAppIos
          this.memberInfo.is_priview = data.is_priview
          this.memberInfo.letterCount = data.letterCount
          this.memberInfo.is_checkin = data.is_checkin
          this.memberInfo.coupon_num = data.coupon_num
          this.memberInfo.collection_num = data.collection_num
          this.memberInfo.all_total = data.all_total
          this.memberInfo.wait_total = data.wait_total
          this.memberInfo.send_total = data.send_total
          this.memberInfo.fina_total = data.fina_total
          this.memberInfo.ispay_total = data.ispay_total
          this.memberInfo.is_allow_exchange = data.is_allow_exchange
          this.memberInfo.is_allow_return = data.is_allow_return
          this.memberInfo.return_total = data.return_total
          this.memberInfo.wait_comment_list = data.wait_comment_list
          this.memberInfo.is_user_img = data.common_center_parameter.is_user_img
          this.memberInfo.user_img_link = data.common_center_parameter.user_img_link
          this.memberInfo.user_img_ggt = data.common_center_parameter.user_img_ggt
          this.memberInfo.show_auction = data.show_auction
          this.memberInfo.is_try = data.is_try
          this.memberInfo.show_numerous = data.show_numerous
          this.memberInfo.open_chuan_bo_bao = data.open_chuan_bo_bao
          this.memberInfo.chuan_bo_bao_url = data.chuan_bo_bao_url
          this.memberInfo.collect_url = data.collect_url // 众筹列表页老地址
          this.memberInfo.is_hide_qiandao = data.is_hide_qiandao || ''
          this.memberInfo.show_dls_upgrade = data.show_dls_upgrade || ''
          this.memberInfo.show_micro_course = data.show_micro_course || ''
          this.memberInfo.smallapp_bind_phone = data.smallapp_bind_phone
          // x+1 链动中心 start
          this.memberData.is_chaining = data.is_chaining || 0
          this.memberData.is_show_chaining = data.is_show_chaining
          // x+1 链动中心 end
          this.memberInfo.is_comment = data.is_comment || 0
          this.memberInfo.is_display_sharer = data.is_display_sharer || 0
          // 复制中心 start
          this.memberData.has_replicate_rank = data.has_replicate_rank || 0
          this.memberData.is_show_replicate_center = data.is_show_replicate_center
          // 复制中心 end
          // 通联汇付分账开户
          if (data.is_show_open_account == 1) {
            this.memberInfo.tlfz_info = data.tlfz_info
            if (data.tlfz_info.tlfz_company_open_account == 1 && data.tlfz_info.tlfz_person_open_account == 1) {
              this.memberInfo.is_opened = 0
            } else {
              this.memberInfo.is_opened = data.is_show_open_account
            }
          } else if (data.is_show_open_account == 2) {

            if (data.adapay_info.adapay_company_apply_status !=0 && data.adapay_info.adapay_company_apply_status !=2 && data.adapay_info.step == 2) {
              this.memberInfo.is_opened = 0
            } else {
              this.memberInfo.is_opened = data.is_show_open_account
              this.memberInfo.adapay_info = data.adapay_info
            }
          }
          if (this.memberInfo.is_hide_qiandao == 1) {
            this.memberInfo.showToggle = false
          }
          this.isAgreement = small.wxCache('isAgreement')
          // 小屋定制
          this.memberInfo.xiaowu_dz = data.xiaowu_dz
          if (data.xiaowu_dz == 1) {
            if (data.my_agent) {
              this.memberInfo.my_agent = data.my_agent
            }
          }
          // 我的导师定制
          this.memberInfo.is_my_mentor = data.is_my_mentor
          if (data.is_my_mentor == 1) {
            this.memberInfo.my_mentor_qrcode_id = data.my_mentor_qrcode_id
            this.memberInfo.my_mentor_wx_id = data.my_mentor_wx_id
          }
          // 小黄鱼定制
          this.memberInfo.is_dz_xhy = data.is_dz_xhy
          // 薇曼定制
          this.memberInfo.is_wm_dz = data.is_wm_dz
          // 上海透缇
          this.memberInfo.is_ti_dz = data.is_ti_dz
          // 乐拍拍
          this.memberInfo.lpp_dz = data.lpp_dz
          // 欧普定制
          this.memberInfo.is_op_dz = data.is_op_dz
          //  常俊海定制 start
          if (data.cjh_dz) {
            this.memberInfo.cjh_dz = data.cjh_dz
          }//  常俊海定制 start
          if (data.cjh_dz) {
            this.memberInfo.cjh_dz = data.cjh_dz
          }
          //  梅之音生物 定制 start
          if (data.weixin_account) {
            this.weixin_account = data.weixin_account
          }
          // 慈善关爱金 定制
          this.memberInfo.charity_compassion_dz = data.charity_compassion_dz || 0
          this.memberInfo.charity_compassion_money = data.charity_compassion_money || '0.00'
          // 自定义会员等级背景图和文字颜色
          this.memberInfo.membership_level_img = data.membership_level_img || 'https://img.wifenxiao.com/h5-wfx/images/user/member/membership_card.png'
          this.memberInfo.membership_level_color = data.membership_level_color || '#fbd791'
          // 现金积分 定制
          if (data.dz_cash_point) {
            this.memberInfo.dz_cash_point = data.dz_cash_point
            this.memberInfo.dz_cash_point_name = data.cash_point_alais
            const cashPoint = {
              dz_cash_point: data.dz_cash_point,
              cash_point_alais: data.cash_point_alais
            }
            StoreSave.saveLocal('cashPoint', cashPoint)
          }
          this.is_dz()
          // 定制 职乐-通联二选一
          this.memberInfo.is_member_select = data.is_member_select
          this.memberInfo.dz_fz_member_type = data.dz_fz_member_type
          // 莱特妮丝 ai 定制
          this.memberInfo.is_skin_detection_dz = data.is_skin_detection_dz

          // 百佳华余额体系定制
          this.memberInfo.bjh_balance_dz = data.bjh_balance_dz
          this.memberInfo.bjh_balance = data.bjh_balance
        } else {
          this.$Error(res.msg)
        }
      })
    },
    // 更新昵称和会员头像
    renderAvatar() {
      this.avatarUrl= this.memberInfo.avatar
      this.nicknameVal = this.memberInfo.nickname
      this.avatarImg = this.memberInfo.avatar
      this.modifyUserPop = true
    },
    closeCancel() {
      this.modifyUserPop = false
    },
    onChooseAvatar(e) {
      this.avatarImg = e.detail.avatarUrl
      // UploadImgBtn(e.detail.avatarUrl)
      // console.log('e.detail', e.detail.avatarUrl)
      const that = this
      wx.uploadFile({
        url: `${small.globalData.appApiUrl}/CommunityApi/uploadImg?sid=${small.globalData.shopId}`,
        filePath: e.detail.avatarUrl,
        name: 'file',
        header: {
          'X-MAPP-ORIGIN': small.globalData.origin
        },
        formData: {},
        success(res) {
          // console.log('res', res)
          that.avatarUrl = res.data
          wx.hideToast({
            success() {
              // console.log('success close');
            }
          })
        },
        fail(res) {
          // console.log('fail', res)
          that.avatarImg = 'https://img.wifenxiao.com/h5-wfx/images/default_avatar.jpg'
          that.avatarUrl = 'https://img.wifenxiao.com/h5-wfx/images/default_avatar.jpg'
          wx.showModal({
            title: '提示',
            content: res.errMsg,
            showCancel: false,
            success: (res) => {

            }
          })
          // console.log('接口调用失败')
        }
      })
    },
    inputChange(e) {
      // console.log('inputChange', e.detail.value)
      this.nicknameVal = e.detail.value
    },
    submitClick() {
      if (this.avatarUrl == 'https://img.wifenxiao.com/h5-wfx/images/default_avatar.jpg') {
        this.$Error('头像不能为空')
        return
      }
      else if (!this.nicknameVal.trim()) {
        this.$Error('昵称不能为空')
        return
      } else if (this.nicknameVal == '微信用户') {
        this.$Error('请修改昵称')
        return
      } else {
        wx.showLoading()
        saveInformation({
          headimgurl: this.avatarUrl,
          nickname: this.nicknameVal
        }).then(res => {
          this.$loadingWrap.close()
          if (res.status == 1) {
            wx.hideLoading()
            // this.$Error('个人信息修改成功！')
            setTimeout(() => {
              // let memberInfo = {}
              // memberInfo.avatar = this.avatarUrl
              // memberInfo.nickname = this.nicknameVal
              // prevPage.setData({  //将要传递的值直接在此处setData,上一个页面就会执行这里的操作
              //   memberInfo
              // })
              // wx.navigateBack({
              //   delta: 1
              // })
              this.modifyUserPop = false
              this.isSub = true
              this.init()
            }, 1000)
          } else {
            this.$Error(res.msg)
          }

        })

      }

    },
      /**
     * 上传图片
     */
    UploadImgBtn() {
      small.wxUploadFile(1).then((data) => {
        // console.log('data', data)
        this.avatarImg = data[0]
      })
    },
    // 更新站内信
    uptMsgInfoFn() {
      uptMsgInfo().then(res => {
        if (res.status == 1) {
          this.letterCount = res.data.num
        }
      })
    },
    // 退出登录
    loginOut() {
      quit().then(res => {
        if (res.status == 1) {
          window.location.href = res.data
        } else {
          this.$Error(res.msg)
        }
      })
    },
    // 切换签到和会员权益
    // toggleLevelQd() {
    //   this.memberInfo.showToggle = !this.memberInfo.showToggle
    // },
    // 定制：显示我的导师
    showMyTeacherPop() {
      this.showMyTeacher = true
    },
    // 复制
    copyMentorWx(text, e) {
      // 小程序复制使用wx的复制版
      wx.setClipboardData({
        data: text,
        success (res) {
          wx.getClipboardData({
            success(res) {
              wx.showToast({
                title: '复制成功',
                icon: 'none',
              });
            }
          })
        }
      })
      this.showMyTeacher = false
    },
    // 定制：隐藏我的导师
    hideMyTeacherPop() {
      this.showMyTeacher = false
    },
    is_dz() {
      const shop = this.$route.query.sid
      const is_waterCleaner = this.$_shop('$_waterCleaner', shop)
      const is_JTJK_DZ = this.$_shop('$_JTJK_DZ', shop)
      this.memberInfo.is_dz_waterCleaner = is_waterCleaner
      this.memberInfo.is_JTJK_DZ = is_JTJK_DZ
    },
    // 切换user-id
    editUserId() {
      this.editInfo.show = true
    },
    // 获取当前的userid数据
    getUserData() {
      getUsers().then(res => {
        this.userStatus = res.status
        this.editInfo.editInfoData = res.data
      })
    },
    // 刷新页面
    RefreshPage(url) {
      openPage(url, 1)
    },
    // 职乐-通联分账类型修改
    selectMemberType() {
      this.show_member_select = true
    },
    menmberTypeSelected() {
      this.show_member_select = false
      this.init()
    }
  }
})
</script>

<style lang="scss">
@import "../../../styles/user/index.scss";
.member-container {
  .qiandao .icon_linkto {
    display: inline-block;
    width: 9px;
    height: 18px;
  }
  //定制 我的导师
  .my_teacher {
    position: absolute;
    top: 30px;
    right: 100px;
    background: url("https://img.wifenxiao.com/h5-wfx/images/user/member/teacher.png") center no-repeat;
    background-size: contain;
    z-index: 10;
    width: 46px;
    height: 46px;
  }
  .detail_qrcode_box {
    overflow: initial;
    width: 80%;
    height: 70%;
    background: #f00d3a;
    .closed_box {
      position: absolute;
      right: -30px;
      top: -30px;
      width: 60px;
      height: 60px;
      border-radius: 50%;
      background: #fff url("https://img.wifenxiao.com/h5-wfx/images/user/member/teacher_close.png")
        center no-repeat;
    }
    .content {
      width: 100%;
      height: 80%;
      position: relative;
      overflow: hidden;
      .h {
        width: 200%;
        height: 100%;
        border-radius: 0 0 50% 50%;
        background-color: #fff;
        position: absolute;
        bottom: 0;
        left: 50%;
        transform: translateX(-50%);
        overflow: hidden;
        .detail_qrcode_content {
          width: 40%;
          position: absolute;
          top: 7%;
          bottom: 0;
          left: 50%;
          transform: translateX(-50%);
          text-align: center;
          .title {
            font-size: 40px;
            line-height: 1.3;
            font-family: "黑体";
            font-weight: bold;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
          }
          p {
            margin-top: 20px;
            font-size: 26px;
            color: #9c9c9c;
          }
          div {
            width: 90%;
            margin: 5% auto 0;
            border: 1px solid #3f4251;
            border-radius: 10px;
            overflow: hidden;
            box-sizing: content-box;
            img {
              display: block;
              width: 100%;
              height: auto;
            }
          }
        }
      }
    }
    .btn {
      width: 80%;
      margin: 0 auto;
      button {
        width: 100%;
        height: 60px;
        border: 2px solid #f00d3a;
        border-radius: 30px;
        border: none;
        outline: none;
        margin-top: 3%;
        font-family: "黑体";
      }
      .copy {
        font-size: 28px;
        background-color: #fff;
        color: #f00d3a;
        font-weight: 700;
      }

      .noWarn {
        border: 2px solid #fff;
        background-color: #f00d3a;
        color: #fff;
      }
    }
  }
  // 修改userid
  .edit-userid-btn {
    font-size: 35px;
    display: inline-block;
    .icon-edituserid {
      margin-bottom: 5px;
    }
  }
}

  .avatarInfo_wraps{
    padding: 32px;
    .text {
      padding: 40px 0;
      font-size: 34px;
      font-weight: 500;
    }
    .shop-name {
      display: flex;
      align-items: center;
      font-weight: 500;
      font-size: 30px;
      img {
        width: 64px;
        height: 64px;
        border-radius: 64px;
        margin-right: 16px;
      }
      span {
        margin-left: 20px;
      }
    }
    .avatar {
      width: 100%;
      background: url("https://img.wifenxiao.com/h5-wfx/images/arrow_R.png") right center no-repeat;
      img {
        width: 80px;
        height: 80px;
        border-radius: 80px;
        position: relative;
        top: 12px;
      }
    }
    .nickname{
      width: 100%;
      height: 114px;
      line-height: 114px;
      border-bottom: 2px solid #E5E6EB;
      // margin-top: 50px;
      // padding: 18px 0;
      display: flex;
      // justify-content: space-between;
      align-items: center;
      .view-title{
        width: 100px;
        font-size: 30px;
        color: #333333;
        margin-right: 36px;
      }
      input, .nickname-title {
        width: 100%;
        height: 114px;
        line-height: 114px;
        font-size: 32px;
        color: #333333;
        text-align: left;
      }
    }

    .submit-btn{
      width: 688px;
      height: 80px;
      text-align: center;
      line-height: 80px;
      // border-radius: 72px;
      font-size: 28px;
      margin-top: 48px;
      color: white;
      background: #FF2146;
    }
    .cancel-btn {
      width: 688px;
      height: 80px;
      text-align: center;
      line-height: 80px;
      // border-radius: 72px;
      font-size: 28px;
      color: #999;
      background: #fff;
    }
  }
  .infoPanel {
    padding-bottom: 20px!important
  }
</style>
